package javabase.socket;

import java.io.DataInputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServerTest {

    public static void main(String[] args) throws Exception {
        try (ServerSocket serverSocket = new ServerSocket(1000)) {
            // 接受客户端的请求并返回socket对象，以便和客户端交互，
            while (true) {
                Socket socket = serverSocket.accept();
                System.out.println("A Client Connected!");
                DataInputStream dis = new DataInputStream(socket.getInputStream());
                String str = dis.readUTF();
                System.out.println(str);
            }

        }

    }

}
